/**
 * 医案基本检索
 * @param condition
 * @param basepath
 */		
function simpleSearch(condition,basepath){ 
	var qstr = ge("q").value; 
	var qtypeobj = ge("qtype");
	var qtype = null;
	if(null != qtypeobj)
		qtype= qtypeobj.value;
	var paramstr = "?q=" + qstr + '&qtype='+qtype;
	document.getElementById("searchtype").value='1'; 
  	document.getElementById("caselist").src= basepath +"search/simplecasesearch.do"+paramstr;
  	
 	searchResultGroupbyYear(paramstr+'&searchtype=1',basepath);
 	//loadPenameGroupdata(onestr,basepath);
}
function groupSearch(contextpath,paramstrvalue){
	var searchtype = document.getElementById("searchtype").value;
	if("2" == searchtype){
		var dname = ge('dname').value;
		var zhenghou = ge('zhenghou').value;
		var zhengzhuang = ge('zhengzhuang').value;
		var yaofangmc = ge('yaofangmc').value;
		var xueweimc = ge('xueweimc').value;
		var herbname = ge('herbname').value;
		var disname = ge('disname').value;
		var wenti = ge('wenti').value;
		var author = ge('author').value; 
	    var clevel = ge('clevel');
	    var clevelvalue =''
	    if(clevel.checked)
	    	clevelvalue = clevel.value;
	    var plevel = ge('plevel');
	    var plevelvalue =''
	    if(plevel.checked)
	    	plevelvalue = plevel.value;
	    var flevel = ge('flevel');
	    var flevelvalue =''
	    if(flevel.checked)
	    	flevelvalue = flevel.value;
	    var iszy = '';
	    var isxy = '';
	    var isam = '';
	    var iszj = '';
	    if(ge('iszy').checked)
	    	iszy = '1';
	    if(ge('isxy').checked)
	    	isxy = '1';
	    if(ge('isam').checked)
	    	isam = '1';
	    if(ge('iszj').checked)
	    	iszj = '1';
	    
		var paramstr = '?dname=' + dname +'&iszy='+iszy+'&isxy='+isxy+'&isam='+isam+'&iszj='+iszj+'&zhenghou=' + zhenghou + '&clevel='+clevelvalue + '&plevel='+plevelvalue +'&flevel='+flevelvalue+'&zhengzhuang='+zhengzhuang + '&yaofangmc='
		               +yaofangmc+'&xueweimc='+xueweimc+'&herbname='+herbname+'&disname='+disname+'&wenti='+wenti+'&author='+author;
	  	document.getElementById("caselist").src= contextpath +"/search/complexcasesearch.do"+paramstr+"&searchtype=2"+paramstrvalue;
	  	
 	}else{
 		var qstr = ge("q").value; 
		var qtypeobj = ge("qtype");
		var qtype = null;
		if(null != qtypeobj)
			qtype= qtypeobj.value;
		var paramstr = "?q=" + qstr + '&qtype='+qtype;
		document.getElementById("searchtype").value='1';  
	  	document.getElementById("caselist").src= contextpath +"/search/simplecasesearch.do"+paramstr+"&searchtype=1"+paramstrvalue; 
	}
}
/**
 * 医案高级检索
 * @param condition
 * @param basepath
 */		
function comflexSearch(condition,basepath){
	 
	var dname = ge('dname').value;
	var zhenghou = ge('zhenghou').value;
	var zhengzhuang = ge('zhengzhuang').value;
	var yaofangmc = ge('yaofangmc').value;
	var xueweimc = ge('xueweimc').value;
	var herbname = ge('herbname').value;
	var disname = ge('disname').value;
	var wenti = ge('wenti').value;
	var author = ge('author').value; 
    var clevel = ge('clevel');
    var clevelvalue =''
    if(clevel.checked)
    	clevelvalue = clevel.value;
    var plevel = ge('plevel');
    var plevelvalue =''
    if(plevel.checked)
    	plevelvalue = plevel.value;
    var flevel = ge('flevel');
    var flevelvalue =''
    if(flevel.checked)
    	flevelvalue = flevel.value;
    var iszy = '';
    var isxy = '';
    var isam = '';
    var iszj = '';
    if(ge('iszy').checked)
    	iszy = '1';
    if(ge('isxy').checked)
    	isxy = '1';
    if(ge('isam').checked)
    	isam = '1';
    if(ge('iszj').checked)
    	iszj = '1';
    
	var paramstr = '?dname=' + dname +'&iszy='+iszy+'&isxy='+isxy+'&isam='+isam+'&iszj='+iszj+'&zhenghou=' + zhenghou + '&clevel='+clevelvalue + '&plevel='+plevelvalue +'&flevel='+flevelvalue+'&zhengzhuang='+zhengzhuang + '&yaofangmc='
	               +yaofangmc+'&xueweimc='+xueweimc+'&herbname='+herbname+'&disname='+disname+'&wenti='+wenti+'&author='+author;
  	document.getElementById("caselist").src= basepath +"search/complexcasesearch.do"+paramstr;
  	document.getElementById("searchtype").value='2';
  	searchResultGroupbyYear(paramstr+'&searchtype=2',basepath);
}
/**
 * 对查询结果进行分组
 * @param type
 */
function groupSearchresult(type,basepath){
	var searchtype = document.getElementById("searchtype").value; 
	var paramstr = '';
	var qtype = document.getElementById("qtype"); 
	if('2' == searchtype){
		var dname = ge('dname').value;
		var zhenghou = ge('zhenghou').value;
		var zhengzhuang = ge('zhengzhuang').value;
		var yaofangmc = ge('yaofangmc').value;
		var xueweimc = ge('xueweimc').value;
		var herbname = ge('herbname').value;
		var disname = ge('disname').value;
		var wenti = ge('wenti').value;
		var author = ge('author').value; 
		var clevel = ge('clevel'); 
	    var clevelvalue =''
	    if(clevel.checked)
	    	clevelvalue = clevel.value;
	    var plevel = ge('plevel');
	    var plevelvalue =''
	    if(plevel.checked)
	    	plevelvalue = plevel.value;
	    var flevel = ge('flevel');
	    var flevelvalue =''
	    if(flevel.checked)
	    	flevelvalue = flevel.value;
	    var iszy = '';
	    var isxy = '';
	    var isam = '';
	    var iszj = '';
	    if(ge('iszy').checked)
	    	iszy = '1';
	    if(ge('isxy').checked)
	    	isxy = '1';
	    if(ge('isam').checked)
	    	isam = '1';
	    if(ge('iszj').checked)
	    	iszj = '1'; 
	    var qtypevalue = null;
	    if(qtype != null){
	    	qtypevalue = qtype.value;
	    }
		paramstr = '?dname=' + dname + '&qtype='+qtypevalue+'&iszy='+iszy+'&isxy='+isxy+'&isam='+isam+'&iszj='+iszj+'&zhenghou=' + zhenghou + '&clevel='+clevelvalue + '&plevel='+plevelvalue +'&flevel='+flevelvalue+'&zhengzhuang='+zhengzhuang + '&yaofangmc='
		               +yaofangmc+'&xueweimc='+xueweimc+'&herbname='+herbname+'&disname='+disname+'&wenti='+wenti+'&author='+author+'&searchtype=2';
		
	}else{
		 var qtypevalue = null;
		    if(qtype != null){
		    	qtypevalue = qtype.value;
		    }
		var qstr = ge("q").value; 
	    paramstr = '?q=' + qstr + '&searchtype=1&qtype='+qtypevalue; 
	} 
	 
	if(type == '1'){
		searchResultGroupbyYear(paramstr,basepath); 
	}else if(type == '2'){
		searchResultGroupbyHuanzhenl(paramstr,basepath);
	}else if(type == '3'){
		searchResultGroupbyZhichengfj(paramstr,basepath);
	}else if(type == '4'){
		searchResultGroupbyXingyins(paramstr,basepath);
	}else if(type == '5'){
		searchResultGroupbyMlzydj(paramstr,basepath);
	}
	
	
}
 
/**
 * 按文献发表年份分组
 * @param paramstr
 * @param basePath
 */
function searchResultGroupbyYear(paramstr,basePath){  
	$.ajax({   
        type:'GET'  
        ,url: basePath + 'search/groupbyYear.do'+encodeURI(paramstr)
        ,data:'',                           
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",  
        beforeSend:function(data){   
            
        }//发送请求前   
        ,success:function(data){    
        	document.getElementById("loadingimg").style.display='none';
            $('#grouparea').html(data);    
        }//请求成功后   
        ,error:function(data){   
            $('#grouparea').html('数据加载失败.')   
        }//请求错误   
        ,complete:function(data){    

        }   
    });    
}
/**
 * 按患者年龄分组
 * @param paramstr
 * @param basePath
 */
function searchResultGroupbyHuanzhenl(paramstr,basePath){ 
 
	$.ajax({   
        type:'GET'  
        ,url: basePath + 'search/groupbyHuanzhenl.do'+encodeURI(paramstr)
        ,data:'',                           
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",  
        beforeSend:function(data){   
            
        }//发送请求前   
        ,success:function(data){    
        	document.getElementById("loadingimg").style.display='none';
            $('#grouparea').html(data);    
        }//请求成功后   
        ,error:function(data){   
            $('#grouparea').html('数据加载失败.')   
        }//请求错误   
        ,complete:function(data){    

        }   
    });    
}
/**
 * 按行医年数分组
 * @param paramstr
 * @param basePath
 */
function searchResultGroupbyXingyins(paramstr,basePath){ 
	 
	$.ajax({   
        type:'GET'  
        ,url: basePath + 'search/groupbyXingyins.do'+encodeURI(paramstr)
        ,data:'',                           
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",  
        beforeSend:function(data){   
            
        }//发送请求前   
        ,success:function(data){    
        	document.getElementById("loadingimg").style.display='none';
            $('#grouparea').html(data);    
        }//请求成功后   
        ,error:function(data){   
            $('#grouparea').html('数据加载失败.')   
        }//请求错误   
        ,complete:function(data){    

        }   
    });    
}
/**
 * 按职称分级分组
 * @param paramstr
 * @param basePath
 */
function searchResultGroupbyZhichengfj(paramstr,basePath){ 
	 
	$.ajax({   
        type:'GET'  
        ,url: basePath + 'search/groupbyZhichengfj.do'+encodeURI(paramstr)
        ,data:'',                           
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",  
        beforeSend:function(data){   
            
        }//发送请求前   
        ,success:function(data){    
        	document.getElementById("loadingimg").style.display='none';
            $('#grouparea').html(data);    
        }//请求成功后   
        ,error:function(data){   
            $('#grouparea').html('数据加载失败.')   
        }//请求错误   
        ,complete:function(data){    

        }   
    });    
}
/**
 * 按名老中医等级分组
 * @param paramstr
 * @param basePath
 */
function searchResultGroupbyMlzydj(paramstr,basePath){ 
	 
	$.ajax({   
        type:'GET'  
        ,url: basePath + 'search/groupbyMlzydj.do'+encodeURI(paramstr)
        ,data:'',                           
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",  
        beforeSend:function(data){   
        	$('#grouparea').html('');  
        }//发送请求前   
        ,success:function(data){    
        	document.getElementById("loadingimg").style.display='none';
            $('#grouparea').html(data);    
        }//请求成功后   
        ,error:function(data){   
            $('#grouparea').html('数据加载失败.')   
        }//请求错误   
        ,complete:function(data){    

        }   
    });    
}



function getDisnameStrbasic(){
	var disnamestr = "";
	var disnamearr = document.getElementsByName("disnamebasic");
	if(disnamearr != null)
	for(var i =0;i<disnamearr.length;i++){
		var temp = disnamearr[i]; 
		if(temp.checked){
			disnamestr+=temp.value; 
			disnamestr+=',';
		}
	} 
	if(disnamestr == ',')
		disnamestr = ''; 
	return disnamestr;
}
function getDisnameStr(){
	var disnamestr = "";
	var disnamearr = document.getElementsByName("disname");
	if(disnamearr != null)
	for(var i =0;i<disnamearr.length;i++){
		var temp = disnamearr[i];
		if(temp.checked){
			disnamestr+=temp.value; 
			disnamestr+=',';
		}
	} 
	if(disnamestr == ',')
		disnamestr = ''; 
	return disnamestr;
}

/**
 * 获取页面对象
 * @param a
 * @returns
 */
function ge(a) {
	return document.getElementById(a)
}
function test(str)
{
    var test=document.getElementById(str).value;
    if(/[\':;*?~`!@#$%^&+={}\[\]\<\>\(\),]/.test(test))
     {
    	
        alert("不能输入特殊字符!");
        document.getElementById(str).value="";
        document.getElementById(str).focus();
        return false;
     }
}
 


function SignVal1(a) {}
function SignVal(f, c, d) {
	if (c == "sign") {
		d = (d) ? d : ((window.event) ? window.event : "");
		var a = d.keyCode ? d.keyCode : d.which;
		if ((a == 39 && document.all) || a == 34 || a == 59) {
			alert("不能输入：' \" ; 等字符！");
			if (d.keyCode) {
				d.keyCode = 0
			}
		}
	} else {
		if (c == "value") {
			if (window.clipboardData) {
				var b = clipboardData.getData("text");
				if (b.indexOf("'") != -1 || b.indexOf('"') != -1 || b.indexOf(";") != -1 || b.indexOf("\\") != -1 || b.indexOf("/") != -1) {
					alert("不能输入：'、\"、; 等字符！");
					return false
				}
			}
		} else {
			if (c == "input") {
				var b = f.value;
				if (b.indexOf("'") != -1 || b.indexOf('"') != -1 || b.indexOf(";") != -1 || b.indexOf("<") != -1 || b.indexOf(">") != -1 || b.indexOf("\\") != -1 || b.indexOf("/") != -1) {
					return false
				}
			}
		}
	}
	return true
}
function resetAll(){
 	var   obj   =   document.all.tags("input"); 
	for(i=0;i <obj.length;i++){ 
	    if(obj[i].type== "text"){ 
	            obj[i].value   =   ""; 
	    } 
	}
 
}



function issynCheck(){
	   var colselected = document.getElementById("basic_col").value;
	   if('DISNAME' == colselected){
	   		var obj = document.getElementById("issyn");
	   		obj.disabled = false; 
	   		obj.checked = true;
	   }else{
	   		var obj = document.getElementById("issyn");
	   		obj.disabled = true; 
	   		obj.checked = false;
	   }
}
function resetAll(){
 	var   obj   =   document.all.tags("input"); 
	for(i=0;i <obj.length;i++){ 
	    if(obj[i].type== "text"){ 
	            obj[i].value   =   ""; 
	    } 
	}
 
}
 
 
